<script>
	export default {
		globalData: {
			token: '',
			redirected: false, // 标志位，表示是否已经执行过重定向
			authorization_token: '',
		},
		onLaunch: function() {
			// APP 初始化拉取配置、登陆验证、版本更新等操作
			console.log('App Launch')
			this.globalData.authorization_token = uni.getStorageSync('authorization_token');
			// console.log(uni.getStorageSync('authorization_token'),969699)
			if (this.globalData.authorization_token == '') {
				console.log(6666)
				uni.$u.route({
					url: '/pages/mine/login',
				});
			}
		},
		onLoad:function(){
			
		},
		onShow: function() {
			console.log('App Show')
			// if (this.globalData.redirected == false) {
				// this.getMember()
			// }
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			getMember() {
				uni.request({
					url: 'https://tmhyyg.nuaa.edu.cn/api/login/getSocialMemberByToken',
					method: 'get',
					data: {
						token: '',
						authorization_token: uni.getStorageSync('authorization_token'),
						venue_id:'237'
					},
					header: {
						'content-type': 'application/json', //自定义请求头信息
					},
					success: res => {
						console.log(res.data, 'res.data')
						if(res.data.authorization_token == ''){
							onsole.log(999)
							uni.removeStorageSync('authorization_token');
							uni.clearStorage();
							uni.clearStorageSync();
							uni.$u.route({
								url: '/pages/mine/login'
							});
						}
						// if (res.data.url !== '') {
						// 	if (this.globalData.redirected == false) {
						// 		document.location.replace(res.data.url);
						// 	}
						// 	this.globalData.redirected = true; // 设置标志位，表示已经执行了重定向


						// } else {
						// 	console.log('URL为空，无法执行重定向');
						// }
						// }
						// window.location.href = res.data.url
					},

				});
			},

		},
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uview-ui/index.scss';
	/* 自定义公共css */
	@import '@/common/common.scss';
</style>